package org.hydrakyoufeng.stuplatform.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ResultEntity<T> {

    private int code;

    private String msg;

    private T data;

    public static ResultEntity<Object> success() {
        return success("操作成功");
    }

    public static ResultEntity<Object> success(String msg) {
        return success(msg,null);
    }

    public static <T>ResultEntity<T> success(String msg,T data) {
        return new ResultEntity<>(1,msg,data);
    }

    public static ResultEntity<Object> error(String msg) {
        return new ResultEntity<>(0,msg,null);
    }

    public static ResultEntity<Object> error() {
        return error("操作失败");
    }

}
